(function (window, $, undefined) {
  'use strict';

  var addData = {};
  var slideData = {};
  var driverData = {};
  var dicData = {
    adStatus:{
      '0':'停用',
      '1':'启用'
    }
  }

  main(function () {

    var $tableCusHomePage = $('#table-cusHomePage');
    util.jqGrid($tableCusHomePage, {
      url: ajaxURL.COUPON+'/advert/queryListWithPage',
      postData:{
        place:1
      },
      mtype: 'POST',
      serializeGridData: function (postData) {
        return JSON.stringify(postData);
      },
      datatype: 'json',
      // autowidth: true,
      width:1000,
      height: $(window).height() - 320,
      multiselect: true,
      // multiboxonly: true,     //去掉  多选
      // shrinkToFit: false,
      colModel: [
        { name: 'kid', key: true, hidden: true },
        { label: '名称', name: 'name', width: 100 ,formatter: function (v, o, r) {
          return '<a href="javascript:;" class="view" data-id="' + r.kid + '">' + v + '</a>';
        }},
        { label: '状态', name: 'status', width: 100 ,formatter: function(v,o,r){
          return dicData.adStatus[v]||'';
        }},
        // { label: '素材地址', name: '', width: 100 },
        // { label: '时段', name: '', width: 120 },
        { label: '有效期开始时间', name: 'effectiveStartTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }},
        { label: '有效期截至时间', name: 'effectiveEndTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }}
      ],
      loadComplete: function (res) {
        addData = {};
        if (res && res.data) {
          $.each(res.data, function (_, item) {
            addData[item.kid] = item;
          });
        }
      },
      pager: '#pager-cusHomePage'
    });


    var $tableCusCarousel = $('#table-cusCarousel');
    util.jqGrid($tableCusCarousel, {
      url: ajaxURL.COUPON+'/advert/queryListWithPage',
      postData:{
        place:2
      },
      mtype: 'POST',
      serializeGridData: function (postData) {
        return JSON.stringify(postData);
      },
      datatype: 'json',
      // autowidth: true,
      width:1000,
      height: $(window).height() - 320,
      multiselect: true,
      // multiboxonly: true,     //去掉  多选
      // shrinkToFit: false,
      colModel: [
        { name: 'kid', key: true, hidden: true },
        { label: '名称', name: 'name', width: 100 ,formatter: function (v, o, r) {
          return '<a href="javascript:;" class="view" data-id="' + r.kid + '">' + v + '</a>';
        }},
        { label: '状态', name: 'status', width: 100 ,formatter: function(v,o,r){
          return dicData.adStatus[v]||'';
        }},
        // { label: '素材地址', name: '', width: 100 },
        // { label: '时段', name: '', width: 120 },
        { label: '有效期开始时间', name: 'effectiveStartTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }},
        { label: '有效期截至时间', name: 'effectiveEndTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }}
      ],
      loadComplete: function (res) {
        slideData = {};
        if (res && res.data) {
          $.each(res.data, function (_, item) {
            slideData[item.kid] = item;
          });
        }
      },
      pager: '#pager-cusCarousel'
    });


    var $tableDrivHomePage = $('#table-drivHomePage');
    util.jqGrid($tableDrivHomePage, {
      url: ajaxURL.COUPON+'/advert/queryListWithPage',
      postData:{
        place:3
      },
      mtype: 'POST',
      serializeGridData: function (postData) {
        return JSON.stringify(postData);
      },
      datatype: 'json',
      width:1000,
      height: $(window).height() - 320,
      multiselect: true,
      colModel: [
        { name: 'kid', key: true, hidden: true },
        { label: '名称', name: 'name', width: 100 ,formatter: function (v, o, r) {
          return '<a href="javascript:;" class="view" data-id="' + r.kid + '">' + v + '</a>';
        }},
        { label: '状态', name: 'status', width: 100 ,formatter: function(v,o,r){
          return dicData.adStatus[v]||'';
        }},
        { label: '有效期开始时间', name: 'effectiveStartTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }},
        { label: '有效期截至时间', name: 'effectiveEndTime', width: 150 ,formatter: function(v,o,r){
          return util.dateFormat(v)
        }}
      ],
      loadComplete: function (res) {
        driverData = {};
        if (res && res.data) {
          $.each(res.data, function (_, item) {
            driverData[item.kid] = item;
          });
        }
      },
      pager: '#pager-drivHomePage'
    });
    // panes
    $('#pane1').click(function () {
      setTab(1, 4);
    });

    $('#pane2').click(function () {
      setTab(2, 4);
    });

    $('#pane3').click(function () {
      setTab(3, 4);
    });

    // $('#pane4').click(function () {
    //   setTab(4, 4);
    // });

    function setTab(cursel, n) {
      for (var i = 1; i <= n; i++) {
        var s = "#pane" + i;
        var c = "#content" + i;
        if (i == cursel) {
          $(s).attr('class', 'tab-pane-selected');
          $(c).css("display", "block");
        }
        else {
          $(s).attr('class', 'tab-pane');
          $(c).css("display", "none");
        }
      }
    }

    //新增广告图片上传
    function uploadImg(){
      util.upload($('#btn-upload'),function(res){
        util.tip.success('图片上传成功');
        $('#photoImg-preview').attr('src', util.pic(res.data));
        $('#photoImg').val(res.data);
        $('textarea[name="imageAddress"]').val(util.pic(res.data));
      });
    }
    //点击图片预览
    $('#photoImg-preview').click(function () {
      var $thisImg = $(this).attr('src')
      console.log($thisImg)
      if ($thisImg) {
        $('#layer-view-img').find('img').attr('src', $thisImg);
        util.layerOpen({
          title: '查看车辆图片',
          content: $('#layer-view-pic')
        });
      }else{
        util.tip.warn('未上传图片')
      }
    });
    

    laydate.render({
      elem:'#effectiveStartTime',
      type:'datetime'
    });
    laydate.render({
      elem:'#effectiveEndTime',
      type:'datetime'
    });

    //  ----1用户端启动页
    var $layerAdAdd = $('#layer-ad-add');
    var $formAdAdd = $('#form-ad-add');

    var $validateFormAdd = $formAdAdd.validate({
      rules:{
        name: { required: true, maxlength: 20},
        imageAddress: { required: true },
        effectiveStartTime: { required: true },
        effectiveEndTime: { required: true },
        linkAddress: { url: true }
      },
      messages:{
        name: { required: '请输入广告名称', maxlength:'请输入20个以内的字符'},
        imageAddress: { required: '请上传广告图片' },
        effectiveStartTime: { required: '请选择有效期时间' },
        effectiveEndTime: { required: '请选择有效期时间' },
        linkAddress: { url: '请输入正确格式的地址'}
      }
    });

    // 新增广告
    $('#btn-add').click(function () {
      $('#photoImg-preview').attr('src','');
      $layerAdAdd.find(":input").removeAttr('disabled').removeAttr('checked');
      // $layerAdAdd.find('textarea[name="linkAddress"]').attr('disabled','disabled');

      
      util.resetForm($formAdAdd);
      uploadImg();
     
      util.layerOpen2({
        title: '新增广告',
        content: $layerAdAdd,
        area:['560px'],
        btn: ['确认', '取消'],
        yes:function(index){
          var data = util.formData($formAdAdd);
          
          if($validateFormAdd.form()){
            // console.log(data);
            if(data.status == "on"){
              data.status = 1
            }else{
              data.status = 0
            }

            if(data.hasLink == "on"){
              data.hasLink = 1
            }else{
              data.hasLink = 0
            }


            var adImage = [{
              hasLink: data.hasLink,
              imageAddress: data.imageAddress,
              linkAddress: data.linkAddress,
              sort: 1
            }];
            //提交得保存数据
            var postData = {
              adImageList: adImage,
              // "createId": 10,
              effectiveEndTime: util.getTime(data.effectiveEndTime)+'',
              effectiveStartTime: util.getTime(data.effectiveStartTime)+'',
              name: data.name,
              place: 1,
              status: data.status
            };
            
            console.log(postData);
            util.post(ajaxURL.COUPON+'/advert/addAdvert',postData,function(res){
              layer.closeAll();
              util.tip.success('新增成功');
              $tableCusHomePage.trigger('reloadGrid');
            })
          }
        }
      },'正在新建广告，是否退出？');
    });

    // 查看广告
    $tableCusHomePage.on('click','.view',function(){
      

      var $this = $(this);
      var id = $this.data('id');
      // var data = addData[id];


      util.ajax(ajaxURL.COUPON+'/advert/queryAdvert', {
        kid: id,
      }, 'GET', util.resCallback(function (res) {
        var data = res.data;

        data.imageAddress = data.adImageList[0].imageAddress;
        data.linkAddress = data.adImageList[0].linkAddress;
        $('#photoImg-preview').attr('src', data.imageAddress);

        data.effectiveEndTime = util.dateFormat(data.effectiveEndTime);
        data.effectiveStartTime = util.dateFormat(data.effectiveStartTime);
        // console.log(typeof(data.status))
        console.log(data)
        if(data.status == 1){
          $layerAdAdd.find('input[name="status"]').attr('checked','checkde');
        }else{
          $layerAdAdd.find('input[name="status"]').removeAttr('checked');
        }

        if(data.adImageList[0].hasLink === 1){
          $layerAdAdd.find('input[name="hasLink"]').attr('checked','checked');
        }else{
          $layerAdAdd.find('input[name="hasLink"]').removeAttr('checked');
        }
        
        $layerAdAdd.find(':input').attr('disabled','disabled');
        util.resetForm($formAdAdd);
        console.log(data);
        // util.fillForm('#form-vehicle-edit', data);
        util.fillForm($formAdAdd,data)
      }));
      
     

      

      util.layerOpen({
        title: '查看广告',
        content: $('#layer-ad-add'),
        area:['560px'],
        btn: ['确认', '取消'],
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });

    });

    // 修改广告
    $('#btn-edit').click(util.oneCheck($tableCusHomePage, function (id) {
      
      util.ajax(ajaxURL.COUPON+'/advert/queryAdvert', {
        kid: id,
      }, 'GET', util.resCallback(function (res) {
        var data = res.data;

        data.imageAddress = data.adImageList[0].imageAddress;
        data.linkAddress = data.adImageList[0].linkAddress;
        $('#photoImg-preview').attr('src', data.imageAddress);

        data.effectiveEndTime = util.dateFormat(data.effectiveEndTime);
        data.effectiveStartTime = util.dateFormat(data.effectiveStartTime);
        // console.log(typeof(data.status))
        console.log(data)
        if(data.status == 1){
          $layerAdAdd.find('input[name="status"]').attr('checked','checkde');
        }else{
          $layerAdAdd.find('input[name="status"]').removeAttr('checked');
        }

        if(data.adImageList[0].hasLink === 1){
          $layerAdAdd.find('input[name="hasLink"]').attr('checked','checked');
        }else{
          $layerAdAdd.find('input[name="hasLink"]').removeAttr('checked');
        }
        
        $layerAdAdd.find(':input').removeAttr('disabled');
        util.resetForm($formAdAdd);
        console.log(data);
        // util.fillForm('#form-vehicle-edit', data);
        util.fillForm($formAdAdd,data)
      }));


      uploadImg();

      util.layerOpen({
        title: '修改广告',
        area:['560px'],
        content: $('#layer-ad-add'),
        btn: ['确认', '取消'],
        yes:function(index){
          var data = util.formData($formAdAdd);
          
          if($validateFormAdd.form()){
            // console.log(data);
            if(data.status == "on"){
              data.status = 1
            }else{
              data.status = 0
            }

            if(data.hasLink == "on"){
              data.hasLink = 1
            }else{
              data.hasLink = 0
            }


            var adImage = [{
              hasLink: data.hasLink,
              imageAddress: data.imageAddress,
              linkAddress: data.linkAddress,
              sort: 1
            }];
            //提交得保存数据
            var postData = {
              adImageList: adImage,
              // "createId": 10,
              effectiveEndTime: util.getTime(data.effectiveEndTime)+'',
              effectiveStartTime: util.getTime(data.effectiveStartTime)+'',
              name: data.name,
              place: 1,
              status: data.status,
              kid:id,
              updateId:oUser.userId
            };
            
            // console.log(postData);
            util.post(ajaxURL.COUPON+'/advert/updateAdvert',postData,function(res){
              layer.closeAll();
              util.tip.success('修改成功');
              $tableCusHomePage.trigger('reloadGrid');
            })
          }
        }
      },'正在修改广告，是否退出？');
      
    }));

    //删除广告		
		$('#btn-del').click(function(){
			var ids = util.getGridSelectedIds($tableCusHomePage);
			var postData = '';
			for(var i=0;i<ids.length;i++){
				postData += 'kids='+ids[i]+'&';
			}
			postData = postData.substring(0,postData.length-1);
      if(ids.length === 0){
        util.tip.warn('请选择一条数据');
        return false;
      }else{  //删除多条，不同接口
				layer.confirm('确定删除选中记录？', {
					btn:['确定','再想一想'],
					yes:function(idx){
						util.ajax(ajaxURL.COUPON+'/advert/deleteAdvertBatch',postData,'GET',util.resCallback(function(res){
							layer.closeAll();
							util.tip.success('删除成功');
							$tableCusHomePage.trigger('reloadGrid');
						}))
					}
				})
      }
		})

    //  ----2用户端首页轮播
    var $layerSlideAdd = $('#layer-slide-add');
    var $layerSlideView = $('#layer-slide-view');
    var $layerSlideEdit = $('#layer-slide-edit');
    //新增用户端首页轮播
    $('#btn-slide-add').click(function(){
      $layerSlideAdd.find(':input').removeAttr('disabled');

      util.layerOpen({
        title:'新增用户端首页轮播',
        area:['700px;'],
        content:$('#layer-slide-add'),
        btn:['确认','取消'],
        cancel:function(index){
          layer.confirm('确定退出当前页面？',{
            btn:['确认','再想一想'],
            yes:function(idx){
              layer.close(index);
              layer.close(idx);
            }
          });
          return false
        }
      })
    })

    // 用户首页轮播查看
    $tableCusCarousel.on('click','.view',function(){
      // util.ajax('http://192.168.1.110:16101/auto/getAuto', {
      //   kid: id,
      // }, 'GET', util.resCallback(function (res) {
      //   var data = res.data;
      //   util.fillForm('#form-vehicle-edit', data);
      // }));

      util.layerOpen({
        title: '查看广告',
        area:['700px;'],
        content: $('#layer-slide-view'),
        btn: ['确认', '取消'],
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });
    });

    //用户首页轮播修改
    $('#btn-slide-edit').click(util.oneCheck($tableCusCarousel, function (id) {
      // util.ajax('http://192.168.1.110:16101/auto/getAuto', {
      //   kid: id,
      // }, 'GET', util.resCallback(function (res) {
      //   var data = res.data;
      //   util.fillForm('#form-vehicle-edit', data);
      // }));

      $layerSlideEdit.find(':input').removeAttr('disabled');

      util.layerOpen({
        title: '修改广告',
        area:['700px;'],
        content: $('#layer-slide-edit'),
        btn: ['确认', '取消'],
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });
    }));

    //删除广告
    $('#btn-slide-del').click(util.oneCheck($tableCusCarousel,function(id){
      layer.confirm('确定删除本条记录？',{
        btn:['确定', '再想一想'],
        yes:function(idx){
          util.ajax(ajaxURL+'删除广告',util.resCallback(function(res){
            console.log(res)
          }))
        }
      })
    }))

    //  ----3司机端启动页


    laydate.render({
      elem:'#driverEffectiveStartTime',
      type:'datetime'
    })
    laydate.render({
      elem:'#driverEffectiveEndTime',
      type:'datetime'
    })

    function uploadImgDriver(){
      util.upload($('#btn-upload-two'),function(res){
        util.tip.success('图片上传成功');
        $('#photoImg-preview-two').attr('src', util.pic(res.data));
        $('#photoImg-two').val(res.data);
        $('textarea[name="imageAddress"]').val(util.pic(res.data));
      });
    }

    //点击图片预览
    $('#photoImg-preview-two').click(function () {
      var $thisImg = $(this).attr('src')
      console.log($thisImg)
      if ($thisImg) {
        $('#layer-view-img').find('img').attr('src', $thisImg);
        util.layerOpen({
          title: '查看车辆图片',
          content: $('#layer-view-pic')
        });
      }else{
        util.tip.warn('未上传图片')
      }
    });


    var $layerDriverAdd = $('#layer-driver-add');
    var $formDriverAdd = $('#form-driver-add');

    var $validateFormDriverAdd = $formDriverAdd.validate({
      rules:{
        name: { required: true, maxlength: 20 },
        imageAddress: { required: true },
        effectiveStartTime: { required: true },
        effectiveEndTime: { required: true },
        linkAddress: { url: true }
      },
      messages:{
        name: { required: '请输入广告名称', maxlength:'请输入20个以内的字符' },
        imageAddress: { required: '请上传广告图片' },
        effectiveStartTime: { required: '请选择有效期时间' },
        effectiveEndTime: { required: '请选择有效期时间' },
        linkAddress: { url: '请输入正确格式的地址'}
      }
    })
    //新增司机端
    $('#btn-driver-add').click(function(){

      $('#photoImg-preview-two').attr('src','');
      $layerDriverAdd.find(":input").removeAttr('disabled').removeAttr('checked');
      // $layerDriverAdd.find('textarea[name="linkAddress"]').attr('disabled','disabled');

      util.resetForm($formDriverAdd);

      // $layerDriverAdd.find(':input').removeAttr('disabled');
      uploadImgDriver();

      util.layerOpen2({
        title:'新增司机端启动页',
        content:$layerDriverAdd,
        btn:['确认','取消'],
        area:['560px'],
        yes:function(index){
          var data = util.formData($formDriverAdd);
          
          if($validateFormDriverAdd.form()){
            // console.log(data);
            if(data.status == "on"){
              data.status = 1
            }else{
              data.status = 0
            }

            if(data.hasLink == "on"){
              data.hasLink = 1
            }else{
              data.hasLink = 0
            }


            var adImage = [{
              hasLink: data.hasLink,
              imageAddress: data.imageAddress,
              linkAddress: data.linkAddress,
              sort: 1
            }];
            //提交得保存数据
            var postData = {
              adImageList: adImage,
              // "createId": 10,
              effectiveEndTime: util.getTime(data.effectiveEndTime)+'',
              effectiveStartTime: util.getTime(data.effectiveStartTime)+'',
              name: data.name,
              place: 3,
              status: data.status
            };
            
            console.log(postData);
            util.post(ajaxURL.COUPON+'/advert/addAdvert',postData,function(res){
              layer.closeAll();
              util.tip.success('新增成功');
              $tableDrivHomePage.trigger('reloadGrid');
            })
          }
        }
      },'正在新建广告，是否退出？')
    })

    // 司机端启动查看
    $tableDrivHomePage.on('click','.view',function(){
      // util.ajax('http://192.168.1.110:16101/auto/getAuto', {
      //   kid: id,
      // }, 'GET', util.resCallback(function (res) {
      //   var data = res.data;
      //   util.fillForm('#form-vehicle-edit', data);
      // }));
      var $this = $(this);
      var id = $this.data('id');
      // var data = addData[id];


      util.ajax(ajaxURL.COUPON+'/advert/queryAdvert', {
        kid: id,
      }, 'GET', util.resCallback(function (res) {
        var data = res.data;

        data.imageAddress = data.adImageList[0].imageAddress;
        data.linkAddress = data.adImageList[0].linkAddress;
        $('#photoImg-preview-two').attr('src', data.imageAddress);

        data.effectiveEndTime = util.dateFormat(data.effectiveEndTime);
        data.effectiveStartTime = util.dateFormat(data.effectiveStartTime);
        // console.log(typeof(data.status))
        if(data.status == 1){
          $layerDriverAdd.find('input[name="status"]').attr('checked','checkde');
        }else{
          $layerDriverAdd.find('input[name="status"]').removeAttr('checked');
        }

        if(data.adImageList[0].hasLink === 1){
          $layerDriverAdd.find('input[name="hasLink"]').attr('checked','checked');
        }else{
          $layerDriverAdd.find('input[name="hasLink"]').removeAttr('checked');
        }
        
        $layerDriverAdd.find(':input').attr('disabled','disabled');
        util.resetForm($formDriverAdd);
        // util.fillForm('#form-vehicle-edit', data);
        util.fillForm($formDriverAdd,data)
      }));

      util.layerOpen({
        title: '查看广告',
        content: $('#layer-driver-add'),
        area:['560px'],
        btn: ['确认', '取消'],
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });



    });

    //司机端启动修改
    $('#btn-driver-edit').click(util.oneCheck($tableDrivHomePage, function (id) {
      util.ajax(ajaxURL.COUPON+'/advert/queryAdvert', {
        kid: id,
      }, 'GET', util.resCallback(function (res) {
        var data = res.data;

        data.imageAddress = data.adImageList[0].imageAddress;
        data.linkAddress = data.adImageList[0].linkAddress;
        $('#photoImg-preview-two').attr('src', data.imageAddress);

        data.effectiveEndTime = util.dateFormat(data.effectiveEndTime);
        data.effectiveStartTime = util.dateFormat(data.effectiveStartTime);
        // console.log(typeof(data.status))
        console.log(data)
        if(data.status == 1){
          $layerDriverAdd.find('input[name="status"]').attr('checked','checkde');
        }else{
          $layerDriverAdd.find('input[name="status"]').removeAttr('checked');
        }

        if(data.adImageList[0].hasLink === 1){
          $layerDriverAdd.find('input[name="hasLink"]').attr('checked','checked');
        }else{
          $layerDriverAdd.find('input[name="hasLink"]').removeAttr('checked');
        }
        
        $layerDriverAdd.find(':input').removeAttr('disabled');
        util.resetForm($formDriverAdd);
        console.log(data);
        // util.fillForm('#form-vehicle-edit', data);
        util.fillForm($formDriverAdd,data)
      }));

      uploadImgDriver();




      util.layerOpen({
        title: '修改广告',
        area:['560px'],
        content: $('#layer-driver-add'),
        btn: ['确认', '取消'],
        yes:function(index){
          var data = util.formData($formDriverAdd);
          
          if($validateFormDriverAdd.form()){
            // console.log(data);
            if(data.status == "on"){
              data.status = 1
            }else{
              data.status = 0
            }

            if(data.hasLink == "on"){
              data.hasLink = 1
            }else{
              data.hasLink = 0
            }


            var adImage = [{
              hasLink: data.hasLink,
              imageAddress: data.imageAddress,
              linkAddress: data.linkAddress,
              sort: 1
            }];
            //提交得保存数据
            var postData = {
              adImageList: adImage,
              // "createId": 10,
              effectiveEndTime: util.getTime(data.effectiveEndTime)+'',
              effectiveStartTime: util.getTime(data.effectiveStartTime)+'',
              name: data.name,
              place: 3,
              status: data.status,
              kid:id,
              updateId:oUser.userId
            };
            
            console.log(postData);
            util.post(ajaxURL.COUPON+'/advert/updateAdvert',postData,function(res){
              layer.closeAll();
              util.tip.success('修改成功');
              $tableDrivHomePage.trigger('reloadGrid');
            })
          }
        }
      },'正在修改广告，是否退出？');
    }));

    //司机端启动删除
    $('#btn-driver-del').click(function(){
      var ids = util.getGridSelectedIds($tableDrivHomePage);
			var postData = '';
			for(var i=0;i<ids.length;i++){
				postData += 'kids='+ids[i]+'&';
			}
			postData = postData.substring(0,postData.length-1);
      if(ids.length === 0){
        util.tip.warn('请选择一条数据');
        return false;
      }else{  //删除多条，不同接口
				layer.confirm('确定删除选中记录？', {
					btn:['确定','再想一想'],
					yes:function(idx){
						util.ajax(ajaxURL.COUPON+'/advert/deleteAdvertBatch',postData,'GET',util.resCallback(function(res){
							layer.closeAll();
							util.tip.success('删除成功');
							$tableDrivHomePage.trigger('reloadGrid');
						}))
					}
				})
      }
    })



  });


})(window, jQuery);
